From 6ece28ffd475578b629d4b54173b0bcd423e707a Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Fri, 3 Oct 2025 16:33:57 +0200 Subject: [PATCH] config: do MaxRtrAdvInterval init at (ra_maxinterval) init time MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcpd/pull/225 Signed-off-by: Álvaro Fernández Rojas --- src/config.c | 7 ++++++- src/router.c | 10 ---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/config.c b/src/config.c index 8a7a9c3..7b0b8fa 100644 --- a/src/config.c +++ b/src/config.c @@ -20,6 +20,7 @@ #include #include "odhcpd.h" +#include "router.h" #include "dhcpv6-pxe.h" static struct blob_buf b; @@ -289,8 +290,12 @@ static void set_interface_defaults(struct interface *iface) iface->ra_flags = ND_RA_FLAG_OTHER; iface->ra_slaac = true; iface->ra_maxinterval = 600; + /* + * RFC4861: MinRtrAdvInterval: Default: 0.33 * MaxRtrAdvInterval If + * MaxRtrAdvInterval >= 9 seconds; otherwise, the Default is MaxRtrAdvInterval. + */ iface->ra_mininterval = iface->ra_maxinterval/3; - iface->ra_lifetime = -1; + iface->ra_lifetime = 3 * iface->ra_maxinterval; /* RFC4861: AdvDefaultLifetime: Default: 3 * MaxRtrAdvInterval */ iface->ra_dns = true; iface->pio_update = false; } diff --git a/src/router.c b/src/router.c index e9b4372..c352d19 100644 --- a/src/router.c +++ b/src/router.c @@ -345,16 +345,6 @@ static int calc_adv_interval(struct interface *iface, uint32_t lowest_found_life if (*maxival > lowest_found_lifetime) *maxival = lowest_found_lifetime; - if (*maxival > MaxRtrAdvInterval) - *maxival = MaxRtrAdvInterval; - else if (*maxival < 4) - *maxival = 4; - - if (minival < MinRtrAdvInterval) - minival = MinRtrAdvInterval; - else if (minival > (*maxival * 3)/4) - minival = (*maxival >= 9 ? *maxival/3 : *maxival); - odhcpd_urandom(&msecs, sizeof(msecs)); msecs = (labs(msecs) % ((*maxival != minival) ? (*maxival - minival)*1000 : 500)) + minival*1000; -- 2.30.2